package gframework.bean.fileChooser;

import java.beans.*;

public class GFileChooserBeanInfo extends SimpleBeanInfo {

    private final static Class beanClass = GFileChooser.class;
    private static BeanDescriptor beanDescriptor = null;
    private static java.awt.Image icon = null;

    @Override
    public BeanDescriptor getBeanDescriptor() {
        beanDescriptor = new BeanDescriptor(beanClass);
        beanDescriptor.setDisplayName("GFileChooser");

        return beanDescriptor;
    }

    @Override
    public PropertyDescriptor[] getPropertyDescriptors() {
        try {
            PropertyDescriptor typePD = new PropertyDescriptor("type", beanClass);
            PropertyDescriptor selectionModePD = new PropertyDescriptor("selectionMode", beanClass);

            PropertyDescriptor rv[] = {typePD, selectionModePD};

            typePD.setPropertyEditorClass(TypePropertyEditor.class);
            selectionModePD.setPropertyEditorClass(SelectionModePropertyEditor.class);

            return rv;

        } catch (IntrospectionException e) {
            throw new Error(e.toString());
        }
    }

    @Override
    public BeanInfo[] getAdditionalBeanInfo() {
        Class superclass = GFileChooser.class.getSuperclass();

        try {
            BeanInfo superBeanInfo = Introspector.getBeanInfo(superclass);

            return new BeanInfo[]{superBeanInfo};

        } catch (IntrospectionException ex) {
            ex.printStackTrace();
            return null;
        }
    }

    @Override
    public java.awt.Image getIcon(int iconKind) {
        if (iconKind == ICON_COLOR_16x16 || iconKind == ICON_MONO_16x16) {
            icon = loadImage("fileChooser16.gif");
        } else if (iconKind == ICON_COLOR_32x32 || iconKind == ICON_MONO_32x32) {
            icon = loadImage("fileChooser32.gif");
        } else {
            icon = null;
        }

        return icon;
    }
}